/* get_time function */

# include <time.h>
# include "../lmntal_ext.h"


void gettime(ReactCxt rc,
                  LmnMembrane *mem,
                  LmnAtom a0, LmnLinkAttr t0)
{
  double *t = LMN_MALLOC(double);

  *t = (double)clock() / CLOCKS_PER_SEC;

  lmn_mem_newlink(mem,
                  a0, LMN_ATTR_MAKE_LINK(0), LMN_ATTR_GET_VALUE(t0),
                  (LmnWord)t, LMN_DBL_ATTR, 0);

  lmn_mem_push_atom(mem, (LmnWord)t, LMN_DBL_ATTR);

}

void init_timer(void)
{
  lmn_register_c_fun("gettime", gettime, 1);
}
